package com.tengju.bff.interfaces.manage.crm.activity.vo;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.time.LocalDate;

/**
 * @author: 大木
 * @date: 2022/1/3 9:57 下午
 */
@Data
@AllArgsConstructor
public class ActivityDetailResVO {

    Long activityId;

    String activityName;

    LocalDate startTime;

    LocalDate endTime;

    Long continueDays;

    Integer activityType;


    /**
     * 取指定周期取交集
     */
    public void subPeriodWithMonth(LocalDate startTime, LocalDate endTime) {

        //交集
        if (!this.endTime.isBefore(startTime) && !this.startTime.isAfter(endTime)) {
            if (startTime.isAfter(this.startTime)) {
                this.startTime = startTime;
            }
            if (endTime.isBefore(this.endTime)) {
                this.endTime = endTime;
            }
            continueDays = this.endTime.toEpochDay() - this.startTime.toEpochDay() + 1;
            return;
        }

        //无交集 返回空
        this.startTime = null;
        this.endTime = null;
        continueDays = 0L;
    }
}
